package com.kaibes.admin.user;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.kaibes.module.user.UserService;
import com.kaibes.web.admin.IconBox;

@Configuration
public class UserBoxInit implements InitializingBean {

	@Autowired
    private UserService userService;
	
	//===============================
    @Bean
    public IconBox userBox() {
        IconBox iconBox = new IconBox() {

            @Override
            public void update() {
                setCount(userService.count());
            }
        };
        iconBox.setSort(3);
        iconBox.setName("用户总数");
        iconBox.setClassAppend("bg-warning");
        iconBox.setIcon("ion-person");
        iconBox.setHref("/admin/user");
        return iconBox;
    }
    
	@Override
	public void afterPropertiesSet() throws Exception {
		userBox().update();
	}

}
